function requireAll(r) {
  return r.keys().map(key => {
    const name = key.replace('./', '').replace('/index.vue', '')
    const component = r(key).default
    return {
      path: `/${name}`,
      name,
      meta: {
        title: component.title || 'demo'
      },
      component: r(key).default
    }
  })
}

const routes = requireAll(require.context('../views', true, /index.vue/)) || []

routes.push({
  path: '*',
  redirect: { name: 'home' }
})

export default routes
